package com.soryin.controller;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.soryin.entity.*;
import com.soryin.service.SoryinService;

/**
 * 表单 处理
 * @author Hello_海生
 * @date 2014年3月21日
 */
@Controller		//注解该类为 controller
@RequestMapping("/soryin")		//用于处理 /login 
public class SoryinController {
	@Autowired
	private SoryinService soryinService;
	
	@RequestMapping("/insert")	//发表
	public void insert(AddressBlock address,ConditionBlock condition,DescriptionBlock description,FigureBlock figure,SetpBlock setp,TimeBlock time,HttpServletRequest request,HttpServletResponse response){

		
		Soryin soryin= new Soryin();
		//缩影信息
		soryin.setEntryTime(new Date());
		User u = new User();
		u.setId(2);
		soryin.setUserId(u);
		
		List<Object> blocks= new ArrayList<Object>();
		//地址信息
		address.setCity("广州");
		address.setSoryinId(soryin);
		blocks.add(address);
		
		//条件信息
		System.out.println("-----------------");
		condition.setSoryinId(soryin);
		blocks.add(condition);
		//描述
		description.setSoryinId(soryin);
		blocks.add(description);
		//任务信息
		figure.setSoryinId(soryin);
		blocks.add(figure);
		//步奏
		setp.setSoryinId(soryin);
		blocks.add(setp);
		//时间
		time.setSoryinId(soryin);
		blocks.add(time);
		//保存
		
		soryinService.save(soryin,blocks);
		
	}
	
}
